// 导出所有控制器
import { BaseController } from './base.controller';
import { UserController } from './user.controller';

export { BaseController, UserController };

// 创建控制器实例
export const userController = new UserController();

/**
 * 控制器工厂
 */
export class ControllerFactory {
  private static instances: Map<string, any> = new Map();

  /**
   * 获取控制器实例（单例模式）
   */
  static getInstance<T>(ControllerClass: new () => T, name: string): T {
    if (!this.instances.has(name)) {
      this.instances.set(name, new ControllerClass());
    }
    return this.instances.get(name);
  }

  /**
   * 获取用户控制器
   */
  static getUserController(): UserController {
    return this.getInstance(UserController, 'user');
  }

  /**
   * 清理所有实例
   */
  static clearInstances(): void {
    this.instances.clear();
  }
}

export default {
  userController,
};